package com.team.lostProperty.service.impl;

import com.team.lostProperty.entity.PushInfo;
import com.team.lostProperty.mapper.PushInfoDao;
import com.team.lostProperty.service.PushInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author duzq
 * @date 2020/07/22 14:35
 **/
@Service
public class PushInfoServiceImpl implements PushInfoService {

    @Autowired
    private PushInfoDao pushInfoDao;

    @Override
    public int getAllCount(int status) {
        return pushInfoDao.getAllCount(status);
    }

    @Override
    public List<PushInfo> getPushInfo(int status, int page, int limit) {
        int start = (page - 1)*limit;
        return pushInfoDao.getPushInfo(status,start,limit);
    }

    @Override
    public PushInfo getPushInfoById(long id) {
        return pushInfoDao.getPushInfoById(id);
    }

    @Override
    public List<PushInfo> selectPushInfo(PushInfo pushInfo) {
        return pushInfoDao.selectPushInfo(pushInfo);
    }

    @Override
    public int deletePushInfo(int id) {
        return pushInfoDao.deletePushInfo(id);
    }

    @Override
    public int updatePushInfo(int status, int pushInfoId) {
        return pushInfoDao.updatePushInfo(status,pushInfoId);
    }

    @Override
    public List<PushInfo> getUserPushInfo(long userId, int start) {
        return pushInfoDao.getUserPushInfo(userId,start);
    }

    @Override
    public List<PushInfo> getUserPushInfo(long userId, int page, int limit) {
        int start = (page - 1)*limit;
        return pushInfoDao.getUserByPush(userId,start,limit);
    }

    @Override
    public List<PushInfo> getByTitle(String title, int start) {
        return pushInfoDao.getByTitle(title,start);
    }

    @Override
    public List<PushInfo> getByContent(String content, int page, int limit) {
        int start = (page - 1)*limit;
        return pushInfoDao.getByContent(content,start,limit);
    }

    @Override
    public void insertPushInfo(PushInfo pushInfo) {
         pushInfoDao.insertPushInfo(pushInfo);
    }

    @Override
    public List<PushInfo> obtainPushInfo(int status, int lastType, int page, int limit){
        int start = (page - 1)*limit;
        return pushInfoDao.obtainPushInfo(status,lastType,start,limit);
    }

    @Override
    public int getPushInfoCount(int status, int lastType){
        return pushInfoDao.getPushInfoCount(status,lastType);
    }

}
